<template>
  <div>
      <video-form  @addchange="addchan" @seachange="seaRest"></video-form>
      <video-table  @page-change="pageReset" :count="videodata.count" :videoList="videodata.videoList"></video-table>
  </div>
</template>
<script lang="ts">
import videoForm from './videoForm.vue'
import videoTable from './videoTable.vue'
export default {
    components:{
      videoForm,
      videoTable
    }
}
</script>
<script lang="ts" setup>
  import {getVideoList} from '../../api/video'
   import {reactive,ref} from 'vue'
    let videodata=reactive({
        videoList:[],
        count:0,
        pageStart:1,
        searchText:'',
        async getVideo(){ //获取视频列表接口
            var res:any=await getVideoList({
              pageStart:videodata.pageStart,
              searchText:videodata.searchText
            })
            console.log(res) 
            if(!res.err){
                videodata.videoList=res.data.list;
                videodata.count=res.data.count;
            }
        }
    })
    videodata.getVideo();
    // 分页改变
    let pageReset=(val:number)=>{
      videodata.pageStart=val;
       videodata.getVideo();
    }
    //添加后重新渲染列表
    let addchan=()=>{
          videodata.getVideo();
    }
    // 搜索
    let seaRest=(sea:string)=>{
      videodata.searchText=sea;
       videodata.getVideo();
    }
</script>
<style lang="less">
  
</style>